# 在forms.py中添加发送通知选项
from django import forms
from .models import Task, TaskImage


class TaskForm(forms.ModelForm):
    send_notification = forms.BooleanField(
        required=False,
        initial=True,
        label='创建后发送钉钉通知',
        help_text='选中此项将在创建任务后发送钉钉通知',
        widget=forms.CheckboxInput(attrs={'class': 'form-check-input'})
    )

    # 图片说明字段
    image_captions = forms.CharField(
        required=False,
        widget=forms.Textarea(attrs={'rows': 3, 'class': 'form-control'}),
        label='图片说明',
        help_text='每行一个说明，对应上传的图片顺序'
    )

    class Meta:
        model = Task
        fields = [
            'title', 'description', 'status', 'due_date',
            'Projectname', 'system', 'ProjectManager', 'ProductManager',
            'DevelopmentEngineer', 'TestEngineer', 'assigned_to',
            'Demandlink', 'Testlink', 'testschedule', 'testprogress',
            'startdate', 'enddate', 'Picturedata', 'Remarks','Testingprocess'
        ]


class TaskImageForm(forms.ModelForm):
    class Meta:
        model = TaskImage
        fields = ['task','image', 'caption']
